#include <gfx/gl20/mesh/staticmesh.h>
#include <gfx/idevice.h>

ceStaticMeshGL20::ceStaticMeshGL20()
  : _mesh(0)
{
  CE_OBJECT_CONSTR
}

ceStaticMeshGL20::~ceStaticMeshGL20()
{
  CE_UNSET(_mesh);
}


void ceStaticMeshGL20::Draw(const ceRenderEnvironment&, iDevice* device)
{
  device->SetStreamSource(0, _mesh->GetVertices());
  device->SetIndices(_mesh->GetIndices());
  device->SetVertexDeclaration(_mesh->GetVertexDeclration());
  device->DrawIndexPrimitives(_mesh->GetPrimitiveType(), _mesh->GetIndexDataType(), _mesh->GetNumberOfPrims(), true);
}

void ceStaticMeshGL20::Update(const ceRenderEnvironment&, iDevice*)
{

}

void ceStaticMeshGL20::SetMesh (ceMesh* mesh)
{
  CE_SET(_mesh, mesh);
}

const ceMesh* ceStaticMeshGL20::GetMesh () const
{
	return _mesh;
}

ceMesh* ceStaticMeshGL20::GetMesh ()
{
	return _mesh;
}


const ceBoundingBox& ceStaticMeshGL20::GetBoundingBox () const
{
  return _mesh->GetBoundingBox();
}
